package com.itheima.controller.user;


import com.itheima.dto.OrdersStatisticsDto;
import com.itheima.result.Result;
import com.itheima.service.UserService;
import com.itheima.dto.UserLoginDTO;
import com.itheima.vo.UserLoginVO;
import com.itheima.vo.UserReportVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;


@RestController
@RequestMapping("/user/user")
@Api(tags = "C端用户相关接口")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDTO userLoginDTO) {
        //0c3DD8000lfQCQ1fZq1007i7rC2DD805
        log.info("{} ", userLoginDTO);
        UserLoginVO userLoginVO = userService.wxLogin(userLoginDTO);
        return Result.success(userLoginVO);
    }

    @GetMapping("/userStatistics")
    public UserReportVO userStatistics(OrdersStatisticsDto statisticsDto) {

        UserReportVO vo = userService.userStatistics(statisticsDto);
        log.info("为{}", vo);
        return vo;
    }

    @GetMapping("/getNewUser")
    public Integer getNewUser(LocalDateTime begin, LocalDateTime end) {
        return userService.getNewUser(begin,end);
    }

    @GetMapping("/selectCount")
    public Integer selectCount(){
        return userService.selectCount();
    }

}